<?php if(!defined('FRAME')) exit('No direct script access allowed');
/**
 * 缓存
 * @author wisoch@hotmail.com
 *
 */
class Cache {
	private $cache;
	private $_cache;
	
	public function __construct($cache = 'file') {
		$cache = strtoupper($cache);
		switch ($cache) {
			case 'FILE' :
				$this->_cache = 'FILE';
				$config = Config::Instance();
				$conf = $config->get('runtime.cache_dir');
				include FRAME . '/cache/File.cache.php';
				$this->cache = new File_cache($conf);
				break;
			case 'MC' :
				$this->_cache = 'MC';
				$config = Config::Instance();
				$conf = $config->get('runtime.cache.mc');
				include FRAME . '/cache/Mc.cache.php';
				$this->cache = new Mc_cache($conf);
				break;
		}
	}
	public function __call($method, $args) {
		if($this->cache && method_exists($this->cache, $method)) {
			return call_user_func_array(array($this->cache, $method), $args);
		}
		trigger_error("Error : call undefined function ".$method, E_USER_ERROR);
    }
}